package com.springcloud.controller;

import com.springcloud.entity.Dept;
import com.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author @1998
 * @date 2021-10-23 1428
 * @description null
 */
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    @PostMapping
    public boolean saveUpdate(@RequestBody Dept dept){
        return deptService.saveOrUpdate(dept);
    }

    @GetMapping("/{id}")
    public Dept saveUpdate(@PathVariable("id") Long id){
        return deptService.getById(id);
    }

    @GetMapping("/list")
    public List<Dept> list(){
        return deptService.list();
    }
}
